package com.xb.cloud.service.client;

/**
 * 服务端相互调用时返回值
 * 
 * @ClassName: ReturnCodes
 * @Description:服务端相互调用时返回值
 * @author: 鲜备科技
 * @date: 2017年12月28日 下午2:40:10
 * 
 * @Copyright: 2017 www.xianbeitech.com Inc. All rights reserved.
 *
 */
public enum ServiceReturnCodes {
	SUCCESS("00000000", "success", "成功"), //
	SYSTEM_EXCEPTION("99999999", "system exception", "系统异常"),

	// API模块名-前四位对应接口，中间2位错误类型（第一位，2.前端入参错误 3.service内部错误 4.调用第三方出错
	// 5.业务异常(业务逻辑)），后2位自定义
	PARAM_IS_NULL("baseuser-10002100", "param is null", "参数为null"),//
	//==================PRODUCT 基础服务模块 start===========================
	PRODUCT_SQL_EXCEPTION("baseproduct-10010101", "SQL exception", "SQL异常"),
	SKU_NOT_EXIST_EXCEPTION("baseproduct-10010201", "sku do not exist", "该商品已经下架"),
	PRODUCT_MONGO_NOT_EXIST_EXCEPTION("baseproduct-10010202", "mongo do not exist the product info", "该商品已经下架"),
	SKU_MONGO_NOT_EXIST_EXCEPTION("baseproduct-10010203", "mongo do not exist the sku info", "该商品已经下架"),
	PRODUCT_NOT_EXIST_EXCEPTION("baseproduct-10010204", "db do not exist the product info", "该商品已经下架"),
	PRODUCT_DETAIL_NOT_EXIST_EXCEPTION("baseproduct-10010205", "db do not exist the product detail info", "该商品已经下架"),
	PRODUCT_PRICE_NOT_EXIST_EXCEPTION("baseproduct-10020207", "db do not exist the product price info", "该商品已经下架"),
	SKU_STOCK_NUM_REAL_LESS_THAN_FROZEN("baseproduct-10020507","real stock num less than real forzen stock num","库存小于冻结库存"),
	
	//==================PRODUCT 基础服务模块 end===========================
	
 

	//商家端 4******
	MERCHANT_NOT_EXIST("merchantcenter-40015101", "merchant not exist", "合法的商家用户不存在"), //
	  //商品发布模块:41
	  PRODUCT_MONGO_NOT_EXIST("productpublish-41015101", "product mongo not exist", "产品的缓存不存在"),
	  PRODUCT_MONGO_SAVE_FAILED("productpublish-41025101", "product mongo save failed", "产品的缓存保存失败"),
	  PRODUCT_SERIES_MONGO_SAVE_FAILED("productpublish-41035101", "product series mongo save failed", "系列产品的系列组合缓存保存失败"),
	  PRODUCT_SERIES_MONGO_NOT_EXIST("productpublish-41045101", "product series mongo not exist", "系列产品的系列组合缓存不存在"),
	//商品管理模块:42
	  PRODUCT_MANAGE_SKU_NOT_EXIST("productpublish-42025001", "sku not exist ", "sku不存在或者已经下架了"),
	  PRODUCT_MANAGE_SKU_NOT_EXIST_OR_ALREADY_UP("productpublish-42015101", "sku not exist or already up", "sku不存在或者已经上架了"),
	  PRODUCT_MANAGE_SKU_NOT_EXIST_OR_ALREADY_DOWN("productpublish-42025101", "sku not exist or already down", "sku不存在或者已经下架了"),
	  PRODUCT_MANAGE_SKU_DONOT_EXIST("productmanage-42025004", "sku not exist ", "sku不存"),
	  
	//订单管理模块:43
	  ORDER_NOT_EXIST("order-43015101", "order not exist   ", "订单不存在"),
	  ORDER_STATUS_INVALID("order-43015201", "order status is invalide  ", "订单状态非法"),
	  ORDER_UPDATE_FAILED("order-43015301", "order update failed", "订单修改失败"),

	  SKU_REAL_STOCK_ERROR("order-43015401", "sku real stock num is error data ", "真实库存数量错误"),
	  SKU_REAL_FREEZON_STOCK_ERROR("order-43015501", "sku real freezon stock num is error data ", "真实冻结库存数量错误"),
	  SKU_STOCK_NOT_MATCH_SKU_ORDER("order-43015601", "sku stock record not match sku order record count ", "库存记录数量和订单记录的数量不匹配"),
	  SKU_STOCK_BATCH_UPDATE_FAILED("order-43015701", "sku  stock batch update failed ", "库存数量批量更新失败"),
	  ORDER_OPERATION_PARAMTER_ERROR("order-43022201", "order operation paramter error ", "订单操作参数错误"),
	//支付 5******
	  PAYMENTCODE_NOT_EXIST("payment-50015201", "Paymentcode not exist", "店铺收款不存在"), //
	  PAYMENT_FLOW_CREATE_ERROR("payment-50015301","payment flow create error","新建下单流水出错"),//
	  PAYMENT_FLOW_UPDATE_ERROR("payment-50015302","payment flow update error","更新下单流水出错"),//
	;
	private final String code;
	private final String msg;
	private final String detail;

	private ServiceReturnCodes(String code, String msg, String detail) {
		this.code = code;
		this.msg = msg;
		this.detail = detail;
	}

	public String getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	public String getDetail() {
		return detail;
	}

	public static ServiceReturnCodes getEnumByCode(String code) {
		for (ServiceReturnCodes p : ServiceReturnCodes.values()) {
			if (p.getCode().equalsIgnoreCase(code)) {
				return p;
			}
		}
		return null;
	}
}
